<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
<meta name="generator" content="pdoc 0.10.0" />
<title>Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main API documentation</title>
<meta name="description" content="This is an example of a plugin (type=&#34;dynamic&#34;), they will be updated during the stated point in the mainloop.
If you need to make a panel that is …" />
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/ir-black.min.css" crossorigin>
<style>
:root {
--highlight-color: #202;
}
html {
scrollbar-face-color: #646464;
scrollbar-base-color: #646464;
scrollbar-3dlight-color: #646464;
scrollbar-highlight-color: #646464;
scrollbar-track-color: #000;
scrollbar-arrow-color: #000;
scrollbar-shadow-color: #646464;
scrollbar-dark-shadow-color: #646464;
}
::-webkit-scrollbar { width: 14px; height: 3px;}
::-webkit-scrollbar-button {
background-color: #000;
height: 3px;}
::-webkit-scrollbar-track {
background-color: #646464;}
::-webkit-scrollbar-track-piece { background-color: #000;}
::-webkit-scrollbar-thumb { height: 50px; background-color: #666; border-radius: 7px;}
::-webkit-scrollbar-corner { background-color: #646464;}
::-webkit-resizer { background-color: #666;}
.flex {
display: flex !important;
}
body {
line-height: 1.5em;
color: #fff;
background-color: #1e1e1e;
font: 14px/1.5 Helvetica, Arial, sans-serif;
margin: 0;
padding: 0;
}
#content {
padding: 20px;
}
#sidebar {
padding: 30px;
overflow: hidden;
}
#sidebar>*:last-child {
margin-bottom: 2cm;
}
.http-server-breadcrumbs {
font-size: 130%;
margin: 0 0 15px 0;
}
#footer {
font-size: .75em;
padding: 5px 30px;
border-top: 1px solid #fff;
text-align: right;
}
#footer p {
margin: 0 0 0 1em;
display: inline-block;
}
#footer p:last-child {
margin-right: 30px;
}
h1,
h2,
h3,
h4,
h5 {
font-weight: 300;
color: #fff;
}
h1 {
font-size: 2.5em;
line-height: 1.1em;
}
h2 {
font-size: 1.75em;
margin: 1em 0 .50em 0;
}
h3 {
font-size: 1.4em;
margin: 25px 0 10px 0;
}
h4 {
margin: 0;
font-size: 105%;
}
h1:target,
h2:target,
h3:target,
h4:target,
h5:target,
h6:target {
background: #1e1e1e;
padding: 0.2em 0;
}
a {
color: #8fd6fc;
text-decoration: none;
transition: color .3s ease-in-out;
}
a:hover {
color: #00a4fc;
}
.title code {
font-weight: bold;
}
h2[id^="header-"] {
margin-top: 2em;
}
.ident {
color: #f6fc85;
}
strong {
color: #8fd6fc;
}
pre code {
background: transparent;
font-size: .8em;
line-height: 1.4em;
}
code {
background: rgba(255, 255, 255, 0.1);
padding: 1px 4px;
overflow-wrap: break-word;
}
h1 code {
background: transparent
}
pre {
background: transparent;
border: 0;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
margin: 1em 0;
padding: 1ex;
}
#http-server-module-list {
display: flex;
flex-flow: column;
}
#http-server-module-list div {
display: flex;
}
#http-server-module-list dt {
min-width: 10%;
}
#http-server-module-list p {
margin-top: 0;
}
.toc ul,
#index {
list-style-type: none;
margin: 0;
padding: 0;
}
#index code {
background: transparent;
}
#index h3 {
border-bottom: 1px solid #ddd;
}
#index ul {
padding: 0;
}
#index h4 {
margin-top: .6em;
font-weight: bold;
}
/* Make TOC lists have 2+ columns when viewport is wide enough.
Assuming ~20-character identifiers and ~30% wide sidebar. */
@media (min-width: 200ex) {
#index .two-column {
column-count: 2
}
}
@media (min-width: 300ex) {
#index .two-column {
column-count: 3
}
}
dl {
margin-bottom: 2em;
}
dl dl:last-child {
margin-bottom: 4em;
}
dd {
margin: 0 0 1em 3em;
}
#header-classes+dl>dd {
margin-bottom: 3em;
}
dd dd {
margin-left: 2em;
}
dd p {
margin: 10px 0;
}
.name {
background: #000;
font-weight: bold;
font-size: .85em;
padding: 5px 10px;
display: inline-block;
min-width: 40%;
}
.name:hover {
background: #0b0b0b;
}
dt:target .name {
background: var(--highlight-color);
}
.name>span:first-child {
white-space: nowrap;
}
.name.class>span:nth-child(2) {
margin-left: .4em;
}
.inherited {
color: #999;
border-left: 5px solid #eee;
padding-left: 1em;
}
.inheritance em {
font-style: normal;
font-weight: bold;
}
.pydefname {
color: #f90;
}
/* Docstrings titles, e.g. in numpydoc format */
.desc h2 {
font-weight: 400;
font-size: 1.25em;
}
.desc h3 {
font-size: 1em;
}
.desc dt code {
background: inherit;
/* Don't grey-back parameters */
}
.source summary,
.git-link-div {
color: #666;
text-align: right;
font-weight: 400;
font-size: .8em;
text-transform: uppercase;
}
.source summary>* {
white-space: nowrap;
cursor: pointer;
}
.git-link {
color: inherit;
margin-left: 1em;
}
.source pre {
max-height: 500px;
overflow: auto;
margin: 0;
}
.source pre code {
font-size: 12px;
overflow: visible;
}
.hlist {
list-style: none;
}
.hlist li {
display: inline;
}
.hlist li:after {
content: ',\2002';
}
.hlist li:last-child:after {
content: none;
}
.hlist .hlist {
display: inline;
padding-left: 1em;
}
img {
max-width: 100%;
}
td {
padding: 0 .5em;
}
.admonition {
padding: .1em .5em;
margin-bottom: 1em;
}
.admonition-title {
font-weight: bold;
}
.admonition.note,
.admonition.info,
.admonition.important {
background: #00a;
}
.admonition.todo,
.admonition.versionadded,
.admonition.tip,
.admonition.hint {
background: #050;
}
.admonition.warning,
.admonition.versionchanged,
.admonition.deprecated {
background: #ec0;
}
.admonition.error,
.admonition.danger,
.admonition.caution {
background: #c20010;
}
p {
color: #fff;
}
</style>
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
</head>
<body>
<main>
<article id="content">
<header>
<h1 class="title">Module <code>Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main</code></h1>
</header>
<section id="section-intro">
<p>This is an example of a plugin (type="dynamic"), they will be updated during the stated point in the mainloop.
If you need to make a panel that is only updated when it's open then check the Panel example!</p>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">&#34;&#34;&#34;
This is an example of a plugin (type=&#34;dynamic&#34;), they will be updated during the stated point in the mainloop.
If you need to make a panel that is only updated when it&#39;s open then check the Panel example!
&#34;&#34;&#34;


from plugins.plugin import PluginInformation
from src.logger import print
from src.mainUI import switchSelectedPlugin, resizeWindow

PluginInfo = PluginInformation(
    name=&#34;CruiseControl&#34;, # This needs to match the folder name under plugins (this would mean plugins\Plugin\main.py)
    description=&#34;This Plugin automatically sets your cruise control speed,\nusing the SDKController.&#34;,
    version=&#34;0.1&#34;,
    author=&#34;Glas42&#34;,
    url=&#34;https://github.com/Glas42/Euro-Truck-Simulator-2-Lane-Assist&#34;,
    type=&#34;dynamic&#34;, # = Panel
    dynamicOrder=&#34;before game&#34;, # Will run the plugin before anything else in the mainloop (data will be empty)
    requires=[&#34;TruckSimAPI&#34;, &#34;SDKController&#34;]
)

import tkinter as tk
from tkinter import ttk
import src.helpers as helpers
import src.mainUI as mainUI
import src.variables as variables
import src.settings as settings
import src.controls as controls
from src.translator import Translate
from tkinter import messagebox
import os

import plugins.DefaultSteering.main as DefaultSteering
import time
import cv2
import numpy as np
import ctypes

controls.RegisterKeybind(&#34;Pause/Resume Automatic Acceleration&#34;,
                         notBoundInfo=&#34;Bind this if you use the CruiseControl\nplugin with automatic acceleration.&#34;,
                         description=&#34;Bind this if you use the CruiseControl\nplugin with automatic acceleration.&#34;)

def UpdateSettings():
    global trafficlightdetectionisenabled
    global navigationdetectionisenabled
    global navigationsymbol_x
    global navigationsymbol_y
    global cruisecontrol_off_set
    global cruisecontrol_off_unset
    global cruisecontrol_off_slowed
    global cruisecontrol_on_set
    global cruisecontrol_on_unset
    global cruisecontrol_on_slowed
    global cruisecontrol_emergency_set
    global cruisecontrol_emergency_unset
    global cruisecontrol_emergency_slowed
    global auto_enable
    global stop_trafficlight
    global trafficlight_accelerate
    global auto_accelerate
    global auto_hazard
    global auto_stop
    global show_symbols
    global acceleration_strength
    global brake_strength
    global cruisespeed_turn
    global cruisespeed_trafficlight
    global wait_for_response
    global wait_for_response_timer
    global last_hazard_light
    global wait_for_response_hazard_light
    global wait_for_response_hazard_light_timer
    global park_brake_target
    global last_park_brake
    global wait_for_response_park_brake
    global wait_for_response_park_brake_timer
    global last_speed
    global last_speedlimit
    global last_cruisecontrolspeed
    global trafficlight_last_time_without
    global trafficlight_last_time_with
    global turnincoming_last_time_with
    global trafficlight_allow_acceleration
    global user_emergency_braking
    global user_emergency_braking_timer
    global lanedetected_timer
    global do_lanedetected_stop
    global last_do_lanedetected_stop
    global last_lanedetected
    global allow_acceleration
    global pauseresume_allow
    global last_park_brake
    
    if &#34;TrafficLightDetection&#34; in settings.GetSettings(&#34;Plugins&#34;, &#34;Enabled&#34;):
        trafficlightdetectionisenabled = True
    else:
        trafficlightdetectionisenabled = False

    if &#34;NavigationDetection&#34; in settings.GetSettings(&#34;Plugins&#34;, &#34;Enabled&#34;):
        navigationdetectionisenabled = True
        centercoord = settings.GetSettings(&#34;NavigationDetectionV3&#34;, &#34;centercoord&#34;, &#34;unset&#34;)
        screencap_x = settings.GetSettings(&#34;bettercam&#34;, &#34;x&#34;)
        screencap_y = settings.GetSettings(&#34;bettercam&#34;, &#34;y&#34;)
        if centercoord == &#34;unset&#34;:
            centercoord = None
        if centercoord != None and screencap_x != None and screencap_y != None:
            navigationsymbol_x = centercoord[0] - screencap_x
            navigationsymbol_y = centercoord[1] - screencap_y
            if navigationsymbol_x &lt; 0:
                navigationsymbol_x = 0
            if navigationsymbol_y &lt; 0:
                navigationsymbol_y = 0
        else:
            navigationsymbol_y = 0
            navigationsymbol_x = 0
    else:
        navigationdetectionisenabled = False

    cruisecontrol_off_set = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_off_set.png&#34;)
    cruisecontrol_off_unset = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_off_unset.png&#34;)
    cruisecontrol_off_slowed = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_off_slowed.png&#34;)
    cruisecontrol_on_set = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_on_set.png&#34;)
    cruisecontrol_on_unset = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_on_unset.png&#34;)
    cruisecontrol_on_slowed = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_on_slowed.png&#34;)
    cruisecontrol_emergency_set = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_emergency_set.png&#34;)
    cruisecontrol_emergency_unset = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_emergency_unset.png&#34;)
    cruisecontrol_emergency_slowed = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_emergency_slowed.png&#34;)

    auto_enable = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_enable&#34;, True)
    stop_trafficlight = settings.GetSettings(&#34;CruiseControl&#34;, &#34;stop_trafficlight&#34;, True)
    trafficlight_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, True)
    auto_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, False)
    auto_hazard = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_hazard&#34;, True)
    auto_stop = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_stop&#34;, False)
    show_symbols = settings.GetSettings(&#34;CruiseControl&#34;, &#34;show_symbols&#34;, True)
    acceleration_strength = settings.GetSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, 50)
    acceleration_strength /= 100
    brake_strength = settings.GetSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, 100)
    brake_strength /= 100

    cruisespeed_turn = 30
    cruisespeed_trafficlight = 0

    wait_for_response = False
    wait_for_response_timer = 0

    last_hazard_light = False
    wait_for_response_hazard_light = False
    wait_for_response_hazard_light_timer = 0

    park_brake_target = False
    last_park_brake = False
    wait_for_response_park_brake = False
    wait_for_response_park_brake_timer = 0

    last_speed = 0
    last_speedlimit = 0
    last_cruisecontrolspeed = 0
    trafficlight_last_time_without = 0
    trafficlight_last_time_with = 0
    turnincoming_last_time_with = 0

    trafficlight_allow_acceleration = False
    user_emergency_braking = False
    user_emergency_braking_timer = 0
    lanedetected_timer = 0
    do_lanedetected_stop = False
    last_do_lanedetected_stop = False
    last_lanedetected = False
    allow_acceleration = True
    pauseresume_allow = True

def plugin(data):
    global trafficlightdetectionisenabled
    global navigationdetectionisenabled
    global navigationsymbol_x
    global navigationsymbol_y
    global cruisecontrol_off_set
    global cruisecontrol_off_unset
    global cruisecontrol_off_slowed
    global cruisecontrol_on_set
    global cruisecontrol_on_unset
    global cruisecontrol_on_slowed
    global cruisecontrol_emergency_set
    global cruisecontrol_emergency_unset
    global cruisecontrol_emergency_slowed
    global auto_enable
    global stop_trafficlight
    global trafficlight_accelerate
    global auto_accelerate
    global auto_hazard
    global auto_stop
    global show_symbols
    global acceleration_strength
    global brake_strength
    global cruisespeed_turn
    global cruisespeed_trafficlight
    global wait_for_response
    global wait_for_response_timer
    global last_hazard_light
    global wait_for_response_hazard_light
    global wait_for_response_hazard_light_timer
    global park_brake_target
    global last_park_brake
    global wait_for_response_park_brake
    global wait_for_response_park_brake_timer
    global last_speed
    global last_speedlimit
    global last_cruisecontrolspeed
    global trafficlight_last_time_without
    global trafficlight_last_time_with
    global turnincoming_last_time_with
    global trafficlight_allow_acceleration
    global user_emergency_braking
    global user_emergency_braking_timer
    global lanedetected_timer
    global do_lanedetected_stop
    global last_do_lanedetected_stop
    global last_lanedetected
    global allow_acceleration
    global pauseresume_allow
    global last_park_brake

    current_time = time.time()
    park_brake_target = False

    try:
        speed = round(data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;speed&#34;]*3.6, 1)
        last_speed = speed
        speedlimit = round(data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;speedLimit&#34;]*3.6, -1)
        if speedlimit != 0 and speedlimit &gt; 0:
            last_speedlimit = speedlimit
        cruisecontrolspeed = round(data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;cruiseControlSpeed&#34;]*3.6, 1)
        if data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userThrottle&#34;] &gt; 0.1:
            user_accelerating = True
        else:
            user_accelerating = False
        user_throttle = data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userThrottle&#34;]
        if data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userBrake&#34;] &gt; 0.1:
            user_braking = True
        else:
            user_braking = False
        if speed &gt;= 0.5 and speed &gt; last_speed:
            user_emergency_braking = False
        if user_accelerating == True:
            user_emergency_braking = False
        if data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userBrake&#34;] &gt; 0.9 and speed &gt; 30 and DefaultSteering.enabled == True:
            user_emergency_braking = True
        hazard_light = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;lightsHazard&#34;]
        park_brake = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;parkBrake&#34;]
        gamepaused = data[&#34;api&#34;][&#34;pause&#34;]
    except:
        speed = last_speed
        speedlimit = last_speedlimit
        cruisecontrolspeed = 0
        user_accelerating = False
        user_throttle = 0
        user_braking = False
        user_emergency_braking = False
        hazard_light = False
        park_brake = False
        gamepaused = False

    if speedlimit != 0 and speedlimit &gt; 0:
        targetspeed = speedlimit
    else:
        if last_speedlimit != 0 and last_speedlimit &gt; 0:
            targetspeed = last_speedlimit
        else:
            targetspeed = 30
    
    if trafficlightdetectionisenabled == True:
        try:
            trafficlight = data[&#34;TrafficLightDetection&#34;][&#34;simple&#34;]
        except:
            trafficlight = &#34;None&#34;
    else:
        trafficlight = &#34;Off&#34;
    if navigationdetectionisenabled == True:
        try:
            if data[&#34;NavigationDetection&#34;][&#34;turnincoming&#34;] == True:
                turnincoming_last_time_with = current_time
            if data[&#34;NavigationDetection&#34;][&#34;lanedetected&#34;] == True:
                lanedetected_timer = current_time
        except:
            pass
    if current_time - 1 &lt; turnincoming_last_time_with:
        targetspeed = cruisespeed_turn
    if current_time - 1 &lt; lanedetected_timer:
        lanedetected = True
    else:
        lanedetected = False

    if trafficlight != &#34;Red&#34;:
        trafficlight_last_time_without = current_time
    else:
        trafficlight_last_time_with = current_time
    if current_time - 0.5 &gt; trafficlight_last_time_without or current_time - 0.5 &lt; trafficlight_last_time_with:
        if stop_trafficlight == True:
            targetspeed = cruisespeed_trafficlight
    
    if targetspeed == 0 and speed &gt; 10:
        trafficlight_allow_acceleration = True

    if current_time - 1 &gt; wait_for_response_timer:
        wait_for_response = False
    if last_cruisecontrolspeed != cruisecontrolspeed:
        wait_for_response = False
        
    if controls.GetKeybindValue(&#34;Pause/Resume Automatic Acceleration&#34;) == True and pauseresume_allow == True:
        if allow_acceleration == True:
            auto_accelerate = False
            trafficlight_accelerate = False
            allow_acceleration = False
        else:
            auto_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, False)
            trafficlight_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, True)
            allow_acceleration = True
        pauseresume_allow = False
    elif controls.GetKeybindValue(&#34;Pause/Resume Automatic Acceleration&#34;) == False:
        pauseresume_allow = True

    try:
        data[&#34;sdk&#34;]
    except:
        data[&#34;sdk&#34;] = {}
    if gamepaused == False and DefaultSteering.enabled == True:
        if speed &gt; 30 and cruisecontrolspeed == 0 and auto_enable == True and wait_for_response == False and targetspeed != 0:
            data[&#34;sdk&#34;][&#34;CruiseControl&#34;] = True
            wait_for_response = True
            wait_for_response_timer = current_time
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
            trafficlight_allow_acceleration = False
        if cruisecontrolspeed != 0 and cruisecontrolspeed &lt; targetspeed and wait_for_response == False and targetspeed != 0:
            data[&#34;sdk&#34;][&#34;CruiseControlIncrease&#34;] = True
            wait_for_response = True
            wait_for_response_timer = current_time
        if cruisecontrolspeed != 0 and cruisecontrolspeed &gt; targetspeed and wait_for_response == False and targetspeed != 0:
            data[&#34;sdk&#34;][&#34;CruiseControlDecrease&#34;] = True
            wait_for_response = True
            wait_for_response_timer = current_time
        if speed &lt; 30 and cruisecontrolspeed == 0 and targetspeed != 0 and trafficlight_accelerate == True and trafficlight_allow_acceleration == True and user_emergency_braking == False and do_lanedetected_stop == False:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = acceleration_strength
            if user_throttle == acceleration_strength:
                user_accelerating = False
            data[&#34;sdk&#34;][&#34;brake&#34;] = 0
        if targetspeed == 0 and abs(speed) &gt; 1 and user_accelerating == False:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
            data[&#34;sdk&#34;][&#34;brake&#34;] = brake_strength
            user_emergency_braking_timer = current_time
        elif targetspeed == 0 and abs(speed) &lt; 1 and user_accelerating == False:
            park_brake_target = True
        if speed &lt; 30 and cruisecontrolspeed == 0 and targetspeed != 0 and auto_accelerate == True and user_emergency_braking == False and do_lanedetected_stop == False:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = acceleration_strength
            if user_throttle == acceleration_strength:
                user_accelerating = False
            data[&#34;sdk&#34;][&#34;brake&#34;] = 0
    else:
        data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
        data[&#34;sdk&#34;][&#34;brake&#34;] = 0

    if auto_hazard == True and do_lanedetected_stop == False:
        if current_time - 1 &lt; user_emergency_braking_timer:
            user_emergency_braking = False
        if hazard_light != last_hazard_light or current_time - 1 &gt;  wait_for_response_hazard_light_timer:
            wait_for_response_hazard_light = False
        if user_emergency_braking == True and hazard_light == False and wait_for_response_hazard_light == False:
            data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
            wait_for_response_hazard_light = True
            wait_for_response_hazard_light_timer = current_time
        if user_emergency_braking == False and hazard_light == True and wait_for_response_hazard_light == False:
            data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
            wait_for_response_hazard_light = True
            wait_for_response_hazard_light_timer = current_time
        if user_emergency_braking == True and abs(speed) &lt; 1 and user_accelerating == False:
            park_brake_target = True

    if auto_stop == True:
        if gamepaused == False and DefaultSteering.enabled == True and lanedetected == False and last_lanedetected == True and user_accelerating == False:
            if navigationdetectionisenabled == True:
                try:
                    frame = data[&#34;frameOriginal&#34;]
                    width = frame.shape[1]
                    height = frame.shape[0]
                except:
                    return data
                hwnd_ets2 = ctypes.windll.user32.FindWindowW(None, &#34;Euro Truck Simulator 2&#34;)
                hwnd_ets2_multiplayer = ctypes.windll.user32.FindWindowW(None, &#34;Euro Truck Simulator 2 Multiplayer&#34;)
                hwnd_ats = ctypes.windll.user32.FindWindowW(None, &#34;American Truck Simulator&#34;)
                hwnd_ats_multiplayer = ctypes.windll.user32.FindWindowW(None, &#34;American Truck Simulator Multiplayer&#34;)
                hwnd_active = ctypes.windll.user32.GetForegroundWindow()
                if hwnd_active == hwnd_ets2 or hwnd_active == hwnd_ats or hwnd_active == hwnd_ets2_multiplayer or hwnd_active == hwnd_ats_multiplayer:
                    lower_blue = np.array([121, 68, 0])
                    upper_blue = np.array([250, 184, 109])
                    mask_blue = cv2.inRange(frame, lower_blue, upper_blue)
                    y, x = np.ogrid[:mask_blue.shape[0], :mask_blue.shape[1]]
                    mask_circle = (x - navigationsymbol_x)**2 + (y - navigationsymbol_y)**2 &lt;= round(width/10)**2
                    mask_blue = np.where(mask_circle, mask_blue, 0)
                    if width != 0 and height != 0:
                        pixel_ratio = cv2.countNonZero(mask_blue) / (width * height)
                    else:
                        pixel_ratio = 0
                    if pixel_ratio &gt; 0.007 and pixel_ratio &lt; 0.01:
                        do_lanedetected_stop = True
            else:
                do_lanedetected_stop = True
        if user_accelerating == True:
            do_lanedetected_stop = False
        if hazard_light != last_hazard_light or current_time - 1 &gt;  wait_for_response_hazard_light_timer:
            wait_for_response_hazard_light = False
    if do_lanedetected_stop == True:
        if abs(speed) &gt; 1:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
            data[&#34;sdk&#34;][&#34;brake&#34;] = 0.1
        elif abs(speed) &lt; 1 and user_accelerating == False:
            park_brake_target = True
        if hazard_light == False and wait_for_response_hazard_light == False:
            data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
            wait_for_response_hazard_light = True
            wait_for_response_hazard_light_timer = current_time
    if do_lanedetected_stop == False and last_do_lanedetected_stop == True and hazard_light == True and wait_for_response_hazard_light == False:
        data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
        wait_for_response_hazard_light = True
        wait_for_response_hazard_light_timer = current_time

    if current_time - 1 &gt; wait_for_response_park_brake_timer:
        wait_for_response_park_brake = False
    if last_park_brake != park_brake:
        wait_for_response_park_brake = False
    if park_brake_target == True and DefaultSteering.enabled == True:
        if park_brake == False and wait_for_response_park_brake == False:
            data[&#34;sdk&#34;][&#34;ParkingBrake&#34;] = True
            wait_for_response_park_brake = True
            wait_for_response_park_brake_timer = current_time
    elif park_brake == True and wait_for_response_park_brake == False and DefaultSteering.enabled == True:
            data[&#34;sdk&#34;][&#34;ParkingBrake&#34;] = True
            wait_for_response_park_brake = True
            wait_for_response_park_brake_timer = current_time

    if show_symbols == True:
        try:
            frame = data[&#34;frame&#34;]
        except:
            return data
        try:
            width = frame.shape[1]
            height = frame.shape[0]
        except:
            return data
        try:
            indicator_left = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;blinkerLeftActive&#34;]
            indicator_right = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;blinkerRightActive&#34;]
        except:
            indicator_left = False
            indicator_right = False
        try:
           turnincoming = data[&#34;NavigationDetection&#34;][&#34;turnincoming&#34;]
        except:
            turnincoming = False
        symbol = cruisecontrol_on_set.copy()
        if cruisecontrolspeed != 0:
            if cruisecontrolspeed == targetspeed and DefaultSteering.enabled == True:
                symbol = cruisecontrol_on_set.copy()
            else:
                symbol = cruisecontrol_on_unset.copy()
            if cruisecontrolspeed != targetspeed:
                symbol = cruisecontrol_on_unset.copy()
            if turnincoming == True:
                symbol = cruisecontrol_on_slowed.copy()
            if user_braking == True or user_accelerating == True:
                symbol = cruisecontrol_on_unset.copy()
        else:
            if cruisecontrolspeed == targetspeed:
                if auto_accelerate == True and DefaultSteering.enabled == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_off_slowed.copy()
                    else:
                        symbol = cruisecontrol_off_set.copy()
                elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_off_slowed.copy()
                    else:
                        symbol = cruisecontrol_off_set.copy()
                else:
                    symbol = cruisecontrol_off_unset.copy()
            elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                if turnincoming == True:
                    symbol = cruisecontrol_off_slowed.copy()
                else:
                    symbol = cruisecontrol_off_set.copy()
            elif auto_accelerate == True and DefaultSteering.enabled == True:
                if turnincoming == True:
                    symbol = cruisecontrol_off_slowed.copy()
                else:
                    symbol = cruisecontrol_off_set.copy()
            else:
                symbol = cruisecontrol_off_unset.copy()
            if user_braking == True or user_accelerating == True:
                symbol = cruisecontrol_off_unset.copy()
        
        if user_emergency_braking == True or do_lanedetected_stop == True:
            if cruisecontrolspeed != 0:
                if cruisecontrolspeed == targetspeed and DefaultSteering.enabled == True:
                    symbol = cruisecontrol_emergency_set.copy()
                else:
                    symbol = cruisecontrol_on_unset.copy()
                if cruisecontrolspeed != targetspeed:
                    symbol = cruisecontrol_emergency_unset.copy()
                if turnincoming == True:
                    symbol = cruisecontrol_emergency_slowed.copy()
                if user_braking == True or user_accelerating == True:
                    symbol = cruisecontrol_emergency_unset.copy()
            else:
                if cruisecontrolspeed == targetspeed:
                    if auto_accelerate == True and DefaultSteering.enabled == True:
                        if turnincoming == True:
                            symbol = cruisecontrol_emergency_slowed.copy()
                        else:
                            symbol = cruisecontrol_emergency_set.copy()
                    elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                        if turnincoming == True:
                            symbol = cruisecontrol_emergency_slowed.copy()
                        else:
                            symbol = cruisecontrol_emergency_set.copy()
                    else:
                        symbol = cruisecontrol_emergency_unset.copy()
                elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_emergency_slowed.copy()
                    else:
                        symbol = cruisecontrol_emergency_set.copy()
                elif auto_accelerate == True and DefaultSteering.enabled == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_emergency_slowed.copy()
                    else:
                        symbol = cruisecontrol_emergency_set.copy()
                else:
                    symbol = cruisecontrol_emergency_unset.copy()
                if user_braking == True or user_accelerating == True:
                    symbol = cruisecontrol_emergency_unset.copy()
        
        symbol_resized = cv2.resize(symbol, (int(0.4 * height), int(0.234375 * height)))
        target_region = frame[int(height/2.8 - 0.2 * height):int(height/2.8 + 0.034375 * height), width - int(0.4 * height):width]
        if indicator_left or indicator_right:
            target_region = frame[int(height/2.8 - 0.2 * height):int(height/2.8 + 0.034375 * height), width - int(0.4 * height):width]
        else:
            target_region = frame[int(height/4 - 0.2 * height):int(height/4 + 0.034375 * height), width - int(0.4 * height):width]
        target_region[:symbol_resized.shape[0], :symbol_resized.shape[1]] = symbol_resized

    if allow_acceleration == False:
        current_text = &#34;Acceleration&#34;
        width_target_current_text = 0.2*width
        fontscale_current_text = 1
        textsize_current_text, _ = cv2.getTextSize(current_text, cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, 1)
        width_current_text, height_current_text = textsize_current_text
        max_count_current_text = 3
        while width_current_text != width_target_current_text:
            fontscale_current_text *= width_target_current_text / width_current_text if width_current_text != 0 else 1
            textsize_current_text, _ = cv2.getTextSize(current_text, cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, 1)
            width_current_text, height_current_text = textsize_current_text
            max_count_current_text -= 1
            if max_count_current_text &lt;= 0:
                break
        thickness_current_text = round(fontscale_current_text*2)
        if thickness_current_text &lt;= 0:
            thickness_current_text = 1
        textsize_paused_text, _ = cv2.getTextSize(&#34;Paused&#34;, cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, 1)
        width_paused_text, height_paused_text = textsize_paused_text
        if indicator_left or indicator_right:
            if show_symbols == True:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.4*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.4*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
            else:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.5*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.5*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
        else:
            if show_symbols == True:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.3*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.3*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
            else:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.4*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.4*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)

    if show_symbols == True:
        try:
            data[&#34;frame&#34;] = frame
        except:
            pass
    
    last_park_brake = park_brake
    last_lanedetected = lanedetected
    last_do_lanedetected_stop = do_lanedetected_stop
    last_hazard_light = hazard_light
    last_cruisecontrolspeed = cruisecontrolspeed
    return data # Plugins need to ALWAYS return the data


# Plugins need to all also have the onEnable and onDisable functions
def onEnable():
    UpdateSettings()
    pass

def onDisable():
    pass

class UI():
    try: # The panel is in a try loop so that the logger can log errors if they occur

        def __init__(self, master) -&gt; None:
            self.master = master # &#34;master&#34; is the mainUI window
            self.exampleFunction()
            resizeWindow(900,600)
        
        def tabFocused(self):
            resizeWindow(900,600)
        
        def destroy(self):
            self.done = True
            self.root.destroy()
            del self
        
        def UpdateScaleValueFromSlider(self):
            self.acceleration.set(self.accelerationSlider.get())
            self.brake.set(self.brakeSlider.get())
            settings.CreateSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, self.accelerationSlider.get())
            settings.CreateSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, self.brakeSlider.get())
            UpdateSettings()
        
        def exampleFunction(self):
            try:
                self.root.destroy() 
            except: pass
            
            self.root = tk.Canvas(self.master, width=800, height=580, border=0, highlightthickness=0)
            self.root.grid_propagate(0) 
            self.root.pack_propagate(0)
            
            notebook = ttk.Notebook(self.root)
            notebook.pack(anchor=&#34;center&#34;, fill=&#34;both&#34;, expand=True)
            
            generalFrame = ttk.Frame(notebook)
            generalFrame.pack()
            
            generalFrame.columnconfigure(0, weight=1)
            generalFrame.columnconfigure(1, weight=1)
            generalFrame.columnconfigure(2, weight=1)
            helpers.MakeLabel(generalFrame, &#34;General&#34;, 0, 0, font=(&#34;Robot&#34;, 12, &#34;bold&#34;), columnspan=3)

            notebook.add(generalFrame, text=Translate(&#34;General&#34;))
            
            self.root.pack(anchor=&#34;center&#34;, expand=False)
            self.root.update()
            
            helpers.MakeCheckButton(generalFrame, &#34;Automatically enable cruise control when available.&#34;, &#34;CruiseControl&#34;, &#34;auto_enable&#34;, 2, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Stop the truck when a red traffic light is detected.\n(requires that the TrafficLightDetection plugin is enabled)&#34;, &#34;CruiseControl&#34;, &#34;stop_trafficlight&#34;, 3, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically accelerate when the red traffic light turns green.&#34;, &#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, 4, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically accelerate to the target speed, even if your truck is standing still.\n(if you disable the steering or pause this feature, the truck will not accelerate to the target speed)&#34;, &#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, 5, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically enable the hazard light, when the user does a emergency stop.&#34;, &#34;CruiseControl&#34;, &#34;auto_hazard&#34;, 6, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically come to a stop and enable the hazard light if no lane is detected.&#34;, &#34;CruiseControl&#34;, &#34;auto_stop&#34;, 7, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Show Cruise Control symbol in the Lane Assist window. (ShowImage Plugin)&#34;, &#34;CruiseControl&#34;, &#34;show_symbols&#34;, 8, 0, width=90, callback=lambda: UpdateSettings())
            
            self.accelerationSlider = tk.Scale(generalFrame, from_=0, to=100, resolution=1, orient=tk.HORIZONTAL, length=480, command=lambda x: self.UpdateScaleValueFromSlider())
            self.accelerationSlider.set(settings.GetSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, 50))
            self.accelerationSlider.grid(row=9, column=0, padx=10, pady=0, columnspan=2)
            self.acceleration = helpers.MakeComboEntry(generalFrame, &#34;Acceleration\nstrength in %&#34;, &#34;CruiseControl&#34;, &#34;acceleration&#34;, 9, 0)
            
            self.brakeSlider = tk.Scale(generalFrame, from_=0, to=100, resolution=1, orient=tk.HORIZONTAL, length=480, command=lambda x: self.UpdateScaleValueFromSlider())
            self.brakeSlider.set(settings.GetSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, 100))
            self.brakeSlider.grid(row=10, column=0, padx=10, pady=0, columnspan=2)
            self.brake = helpers.MakeComboEntry(generalFrame, &#34;Brake\nstrength in %&#34;, &#34;CruiseControl&#34;, &#34;brake&#34;, 10, 0)

            helpers.MakeLabel(generalFrame, &#34;For the best experience, you need to go in the game settings under Gameplay and enable\nthe Adaptive cruise control to the highest possible distance and set the Emergency brake\nsystem to Full detection!&#34;, 11, 0, sticky=&#34;w&#34;)

        def update(self, data): # When the panel is open this function is called each frame 
            self.root.update()
    
    
    except Exception as ex:
        print(ex.args)</code></pre>
</details>
</section>
<section>
</section>
<section>
</section>
<section>
<h2 class="section-title" id="header-functions">Functions</h2>
<dl>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UpdateSettings"><code class="name flex">
<span>def <span class="ident">UpdateSettings</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def UpdateSettings():
    global trafficlightdetectionisenabled
    global navigationdetectionisenabled
    global navigationsymbol_x
    global navigationsymbol_y
    global cruisecontrol_off_set
    global cruisecontrol_off_unset
    global cruisecontrol_off_slowed
    global cruisecontrol_on_set
    global cruisecontrol_on_unset
    global cruisecontrol_on_slowed
    global cruisecontrol_emergency_set
    global cruisecontrol_emergency_unset
    global cruisecontrol_emergency_slowed
    global auto_enable
    global stop_trafficlight
    global trafficlight_accelerate
    global auto_accelerate
    global auto_hazard
    global auto_stop
    global show_symbols
    global acceleration_strength
    global brake_strength
    global cruisespeed_turn
    global cruisespeed_trafficlight
    global wait_for_response
    global wait_for_response_timer
    global last_hazard_light
    global wait_for_response_hazard_light
    global wait_for_response_hazard_light_timer
    global park_brake_target
    global last_park_brake
    global wait_for_response_park_brake
    global wait_for_response_park_brake_timer
    global last_speed
    global last_speedlimit
    global last_cruisecontrolspeed
    global trafficlight_last_time_without
    global trafficlight_last_time_with
    global turnincoming_last_time_with
    global trafficlight_allow_acceleration
    global user_emergency_braking
    global user_emergency_braking_timer
    global lanedetected_timer
    global do_lanedetected_stop
    global last_do_lanedetected_stop
    global last_lanedetected
    global allow_acceleration
    global pauseresume_allow
    global last_park_brake
    
    if &#34;TrafficLightDetection&#34; in settings.GetSettings(&#34;Plugins&#34;, &#34;Enabled&#34;):
        trafficlightdetectionisenabled = True
    else:
        trafficlightdetectionisenabled = False

    if &#34;NavigationDetection&#34; in settings.GetSettings(&#34;Plugins&#34;, &#34;Enabled&#34;):
        navigationdetectionisenabled = True
        centercoord = settings.GetSettings(&#34;NavigationDetectionV3&#34;, &#34;centercoord&#34;, &#34;unset&#34;)
        screencap_x = settings.GetSettings(&#34;bettercam&#34;, &#34;x&#34;)
        screencap_y = settings.GetSettings(&#34;bettercam&#34;, &#34;y&#34;)
        if centercoord == &#34;unset&#34;:
            centercoord = None
        if centercoord != None and screencap_x != None and screencap_y != None:
            navigationsymbol_x = centercoord[0] - screencap_x
            navigationsymbol_y = centercoord[1] - screencap_y
            if navigationsymbol_x &lt; 0:
                navigationsymbol_x = 0
            if navigationsymbol_y &lt; 0:
                navigationsymbol_y = 0
        else:
            navigationsymbol_y = 0
            navigationsymbol_x = 0
    else:
        navigationdetectionisenabled = False

    cruisecontrol_off_set = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_off_set.png&#34;)
    cruisecontrol_off_unset = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_off_unset.png&#34;)
    cruisecontrol_off_slowed = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_off_slowed.png&#34;)
    cruisecontrol_on_set = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_on_set.png&#34;)
    cruisecontrol_on_unset = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_on_unset.png&#34;)
    cruisecontrol_on_slowed = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_on_slowed.png&#34;)
    cruisecontrol_emergency_set = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_emergency_set.png&#34;)
    cruisecontrol_emergency_unset = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_emergency_unset.png&#34;)
    cruisecontrol_emergency_slowed = cv2.imread(variables.PATH + r&#34;\assets\CruiseControl\cruisecontrol_emergency_slowed.png&#34;)

    auto_enable = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_enable&#34;, True)
    stop_trafficlight = settings.GetSettings(&#34;CruiseControl&#34;, &#34;stop_trafficlight&#34;, True)
    trafficlight_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, True)
    auto_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, False)
    auto_hazard = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_hazard&#34;, True)
    auto_stop = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_stop&#34;, False)
    show_symbols = settings.GetSettings(&#34;CruiseControl&#34;, &#34;show_symbols&#34;, True)
    acceleration_strength = settings.GetSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, 50)
    acceleration_strength /= 100
    brake_strength = settings.GetSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, 100)
    brake_strength /= 100

    cruisespeed_turn = 30
    cruisespeed_trafficlight = 0

    wait_for_response = False
    wait_for_response_timer = 0

    last_hazard_light = False
    wait_for_response_hazard_light = False
    wait_for_response_hazard_light_timer = 0

    park_brake_target = False
    last_park_brake = False
    wait_for_response_park_brake = False
    wait_for_response_park_brake_timer = 0

    last_speed = 0
    last_speedlimit = 0
    last_cruisecontrolspeed = 0
    trafficlight_last_time_without = 0
    trafficlight_last_time_with = 0
    turnincoming_last_time_with = 0

    trafficlight_allow_acceleration = False
    user_emergency_braking = False
    user_emergency_braking_timer = 0
    lanedetected_timer = 0
    do_lanedetected_stop = False
    last_do_lanedetected_stop = False
    last_lanedetected = False
    allow_acceleration = True
    pauseresume_allow = True</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.onDisable"><code class="name flex">
<span>def <span class="ident">onDisable</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def onDisable():
    pass</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.onEnable"><code class="name flex">
<span>def <span class="ident">onEnable</span></span>(<span>)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def onEnable():
    UpdateSettings()
    pass</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.plugin"><code class="name flex">
<span>def <span class="ident">plugin</span></span>(<span>data)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def plugin(data):
    global trafficlightdetectionisenabled
    global navigationdetectionisenabled
    global navigationsymbol_x
    global navigationsymbol_y
    global cruisecontrol_off_set
    global cruisecontrol_off_unset
    global cruisecontrol_off_slowed
    global cruisecontrol_on_set
    global cruisecontrol_on_unset
    global cruisecontrol_on_slowed
    global cruisecontrol_emergency_set
    global cruisecontrol_emergency_unset
    global cruisecontrol_emergency_slowed
    global auto_enable
    global stop_trafficlight
    global trafficlight_accelerate
    global auto_accelerate
    global auto_hazard
    global auto_stop
    global show_symbols
    global acceleration_strength
    global brake_strength
    global cruisespeed_turn
    global cruisespeed_trafficlight
    global wait_for_response
    global wait_for_response_timer
    global last_hazard_light
    global wait_for_response_hazard_light
    global wait_for_response_hazard_light_timer
    global park_brake_target
    global last_park_brake
    global wait_for_response_park_brake
    global wait_for_response_park_brake_timer
    global last_speed
    global last_speedlimit
    global last_cruisecontrolspeed
    global trafficlight_last_time_without
    global trafficlight_last_time_with
    global turnincoming_last_time_with
    global trafficlight_allow_acceleration
    global user_emergency_braking
    global user_emergency_braking_timer
    global lanedetected_timer
    global do_lanedetected_stop
    global last_do_lanedetected_stop
    global last_lanedetected
    global allow_acceleration
    global pauseresume_allow
    global last_park_brake

    current_time = time.time()
    park_brake_target = False

    try:
        speed = round(data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;speed&#34;]*3.6, 1)
        last_speed = speed
        speedlimit = round(data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;speedLimit&#34;]*3.6, -1)
        if speedlimit != 0 and speedlimit &gt; 0:
            last_speedlimit = speedlimit
        cruisecontrolspeed = round(data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;cruiseControlSpeed&#34;]*3.6, 1)
        if data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userThrottle&#34;] &gt; 0.1:
            user_accelerating = True
        else:
            user_accelerating = False
        user_throttle = data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userThrottle&#34;]
        if data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userBrake&#34;] &gt; 0.1:
            user_braking = True
        else:
            user_braking = False
        if speed &gt;= 0.5 and speed &gt; last_speed:
            user_emergency_braking = False
        if user_accelerating == True:
            user_emergency_braking = False
        if data[&#34;api&#34;][&#34;truckFloat&#34;][&#34;userBrake&#34;] &gt; 0.9 and speed &gt; 30 and DefaultSteering.enabled == True:
            user_emergency_braking = True
        hazard_light = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;lightsHazard&#34;]
        park_brake = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;parkBrake&#34;]
        gamepaused = data[&#34;api&#34;][&#34;pause&#34;]
    except:
        speed = last_speed
        speedlimit = last_speedlimit
        cruisecontrolspeed = 0
        user_accelerating = False
        user_throttle = 0
        user_braking = False
        user_emergency_braking = False
        hazard_light = False
        park_brake = False
        gamepaused = False

    if speedlimit != 0 and speedlimit &gt; 0:
        targetspeed = speedlimit
    else:
        if last_speedlimit != 0 and last_speedlimit &gt; 0:
            targetspeed = last_speedlimit
        else:
            targetspeed = 30
    
    if trafficlightdetectionisenabled == True:
        try:
            trafficlight = data[&#34;TrafficLightDetection&#34;][&#34;simple&#34;]
        except:
            trafficlight = &#34;None&#34;
    else:
        trafficlight = &#34;Off&#34;
    if navigationdetectionisenabled == True:
        try:
            if data[&#34;NavigationDetection&#34;][&#34;turnincoming&#34;] == True:
                turnincoming_last_time_with = current_time
            if data[&#34;NavigationDetection&#34;][&#34;lanedetected&#34;] == True:
                lanedetected_timer = current_time
        except:
            pass
    if current_time - 1 &lt; turnincoming_last_time_with:
        targetspeed = cruisespeed_turn
    if current_time - 1 &lt; lanedetected_timer:
        lanedetected = True
    else:
        lanedetected = False

    if trafficlight != &#34;Red&#34;:
        trafficlight_last_time_without = current_time
    else:
        trafficlight_last_time_with = current_time
    if current_time - 0.5 &gt; trafficlight_last_time_without or current_time - 0.5 &lt; trafficlight_last_time_with:
        if stop_trafficlight == True:
            targetspeed = cruisespeed_trafficlight
    
    if targetspeed == 0 and speed &gt; 10:
        trafficlight_allow_acceleration = True

    if current_time - 1 &gt; wait_for_response_timer:
        wait_for_response = False
    if last_cruisecontrolspeed != cruisecontrolspeed:
        wait_for_response = False
        
    if controls.GetKeybindValue(&#34;Pause/Resume Automatic Acceleration&#34;) == True and pauseresume_allow == True:
        if allow_acceleration == True:
            auto_accelerate = False
            trafficlight_accelerate = False
            allow_acceleration = False
        else:
            auto_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, False)
            trafficlight_accelerate = settings.GetSettings(&#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, True)
            allow_acceleration = True
        pauseresume_allow = False
    elif controls.GetKeybindValue(&#34;Pause/Resume Automatic Acceleration&#34;) == False:
        pauseresume_allow = True

    try:
        data[&#34;sdk&#34;]
    except:
        data[&#34;sdk&#34;] = {}
    if gamepaused == False and DefaultSteering.enabled == True:
        if speed &gt; 30 and cruisecontrolspeed == 0 and auto_enable == True and wait_for_response == False and targetspeed != 0:
            data[&#34;sdk&#34;][&#34;CruiseControl&#34;] = True
            wait_for_response = True
            wait_for_response_timer = current_time
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
            trafficlight_allow_acceleration = False
        if cruisecontrolspeed != 0 and cruisecontrolspeed &lt; targetspeed and wait_for_response == False and targetspeed != 0:
            data[&#34;sdk&#34;][&#34;CruiseControlIncrease&#34;] = True
            wait_for_response = True
            wait_for_response_timer = current_time
        if cruisecontrolspeed != 0 and cruisecontrolspeed &gt; targetspeed and wait_for_response == False and targetspeed != 0:
            data[&#34;sdk&#34;][&#34;CruiseControlDecrease&#34;] = True
            wait_for_response = True
            wait_for_response_timer = current_time
        if speed &lt; 30 and cruisecontrolspeed == 0 and targetspeed != 0 and trafficlight_accelerate == True and trafficlight_allow_acceleration == True and user_emergency_braking == False and do_lanedetected_stop == False:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = acceleration_strength
            if user_throttle == acceleration_strength:
                user_accelerating = False
            data[&#34;sdk&#34;][&#34;brake&#34;] = 0
        if targetspeed == 0 and abs(speed) &gt; 1 and user_accelerating == False:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
            data[&#34;sdk&#34;][&#34;brake&#34;] = brake_strength
            user_emergency_braking_timer = current_time
        elif targetspeed == 0 and abs(speed) &lt; 1 and user_accelerating == False:
            park_brake_target = True
        if speed &lt; 30 and cruisecontrolspeed == 0 and targetspeed != 0 and auto_accelerate == True and user_emergency_braking == False and do_lanedetected_stop == False:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = acceleration_strength
            if user_throttle == acceleration_strength:
                user_accelerating = False
            data[&#34;sdk&#34;][&#34;brake&#34;] = 0
    else:
        data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
        data[&#34;sdk&#34;][&#34;brake&#34;] = 0

    if auto_hazard == True and do_lanedetected_stop == False:
        if current_time - 1 &lt; user_emergency_braking_timer:
            user_emergency_braking = False
        if hazard_light != last_hazard_light or current_time - 1 &gt;  wait_for_response_hazard_light_timer:
            wait_for_response_hazard_light = False
        if user_emergency_braking == True and hazard_light == False and wait_for_response_hazard_light == False:
            data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
            wait_for_response_hazard_light = True
            wait_for_response_hazard_light_timer = current_time
        if user_emergency_braking == False and hazard_light == True and wait_for_response_hazard_light == False:
            data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
            wait_for_response_hazard_light = True
            wait_for_response_hazard_light_timer = current_time
        if user_emergency_braking == True and abs(speed) &lt; 1 and user_accelerating == False:
            park_brake_target = True

    if auto_stop == True:
        if gamepaused == False and DefaultSteering.enabled == True and lanedetected == False and last_lanedetected == True and user_accelerating == False:
            if navigationdetectionisenabled == True:
                try:
                    frame = data[&#34;frameOriginal&#34;]
                    width = frame.shape[1]
                    height = frame.shape[0]
                except:
                    return data
                hwnd_ets2 = ctypes.windll.user32.FindWindowW(None, &#34;Euro Truck Simulator 2&#34;)
                hwnd_ets2_multiplayer = ctypes.windll.user32.FindWindowW(None, &#34;Euro Truck Simulator 2 Multiplayer&#34;)
                hwnd_ats = ctypes.windll.user32.FindWindowW(None, &#34;American Truck Simulator&#34;)
                hwnd_ats_multiplayer = ctypes.windll.user32.FindWindowW(None, &#34;American Truck Simulator Multiplayer&#34;)
                hwnd_active = ctypes.windll.user32.GetForegroundWindow()
                if hwnd_active == hwnd_ets2 or hwnd_active == hwnd_ats or hwnd_active == hwnd_ets2_multiplayer or hwnd_active == hwnd_ats_multiplayer:
                    lower_blue = np.array([121, 68, 0])
                    upper_blue = np.array([250, 184, 109])
                    mask_blue = cv2.inRange(frame, lower_blue, upper_blue)
                    y, x = np.ogrid[:mask_blue.shape[0], :mask_blue.shape[1]]
                    mask_circle = (x - navigationsymbol_x)**2 + (y - navigationsymbol_y)**2 &lt;= round(width/10)**2
                    mask_blue = np.where(mask_circle, mask_blue, 0)
                    if width != 0 and height != 0:
                        pixel_ratio = cv2.countNonZero(mask_blue) / (width * height)
                    else:
                        pixel_ratio = 0
                    if pixel_ratio &gt; 0.007 and pixel_ratio &lt; 0.01:
                        do_lanedetected_stop = True
            else:
                do_lanedetected_stop = True
        if user_accelerating == True:
            do_lanedetected_stop = False
        if hazard_light != last_hazard_light or current_time - 1 &gt;  wait_for_response_hazard_light_timer:
            wait_for_response_hazard_light = False
    if do_lanedetected_stop == True:
        if abs(speed) &gt; 1:
            data[&#34;sdk&#34;][&#34;acceleration&#34;] = 0
            data[&#34;sdk&#34;][&#34;brake&#34;] = 0.1
        elif abs(speed) &lt; 1 and user_accelerating == False:
            park_brake_target = True
        if hazard_light == False and wait_for_response_hazard_light == False:
            data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
            wait_for_response_hazard_light = True
            wait_for_response_hazard_light_timer = current_time
    if do_lanedetected_stop == False and last_do_lanedetected_stop == True and hazard_light == True and wait_for_response_hazard_light == False:
        data[&#34;sdk&#34;][&#34;Hazards&#34;] = True
        wait_for_response_hazard_light = True
        wait_for_response_hazard_light_timer = current_time

    if current_time - 1 &gt; wait_for_response_park_brake_timer:
        wait_for_response_park_brake = False
    if last_park_brake != park_brake:
        wait_for_response_park_brake = False
    if park_brake_target == True and DefaultSteering.enabled == True:
        if park_brake == False and wait_for_response_park_brake == False:
            data[&#34;sdk&#34;][&#34;ParkingBrake&#34;] = True
            wait_for_response_park_brake = True
            wait_for_response_park_brake_timer = current_time
    elif park_brake == True and wait_for_response_park_brake == False and DefaultSteering.enabled == True:
            data[&#34;sdk&#34;][&#34;ParkingBrake&#34;] = True
            wait_for_response_park_brake = True
            wait_for_response_park_brake_timer = current_time

    if show_symbols == True:
        try:
            frame = data[&#34;frame&#34;]
        except:
            return data
        try:
            width = frame.shape[1]
            height = frame.shape[0]
        except:
            return data
        try:
            indicator_left = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;blinkerLeftActive&#34;]
            indicator_right = data[&#34;api&#34;][&#34;truckBool&#34;][&#34;blinkerRightActive&#34;]
        except:
            indicator_left = False
            indicator_right = False
        try:
           turnincoming = data[&#34;NavigationDetection&#34;][&#34;turnincoming&#34;]
        except:
            turnincoming = False
        symbol = cruisecontrol_on_set.copy()
        if cruisecontrolspeed != 0:
            if cruisecontrolspeed == targetspeed and DefaultSteering.enabled == True:
                symbol = cruisecontrol_on_set.copy()
            else:
                symbol = cruisecontrol_on_unset.copy()
            if cruisecontrolspeed != targetspeed:
                symbol = cruisecontrol_on_unset.copy()
            if turnincoming == True:
                symbol = cruisecontrol_on_slowed.copy()
            if user_braking == True or user_accelerating == True:
                symbol = cruisecontrol_on_unset.copy()
        else:
            if cruisecontrolspeed == targetspeed:
                if auto_accelerate == True and DefaultSteering.enabled == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_off_slowed.copy()
                    else:
                        symbol = cruisecontrol_off_set.copy()
                elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_off_slowed.copy()
                    else:
                        symbol = cruisecontrol_off_set.copy()
                else:
                    symbol = cruisecontrol_off_unset.copy()
            elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                if turnincoming == True:
                    symbol = cruisecontrol_off_slowed.copy()
                else:
                    symbol = cruisecontrol_off_set.copy()
            elif auto_accelerate == True and DefaultSteering.enabled == True:
                if turnincoming == True:
                    symbol = cruisecontrol_off_slowed.copy()
                else:
                    symbol = cruisecontrol_off_set.copy()
            else:
                symbol = cruisecontrol_off_unset.copy()
            if user_braking == True or user_accelerating == True:
                symbol = cruisecontrol_off_unset.copy()
        
        if user_emergency_braking == True or do_lanedetected_stop == True:
            if cruisecontrolspeed != 0:
                if cruisecontrolspeed == targetspeed and DefaultSteering.enabled == True:
                    symbol = cruisecontrol_emergency_set.copy()
                else:
                    symbol = cruisecontrol_on_unset.copy()
                if cruisecontrolspeed != targetspeed:
                    symbol = cruisecontrol_emergency_unset.copy()
                if turnincoming == True:
                    symbol = cruisecontrol_emergency_slowed.copy()
                if user_braking == True or user_accelerating == True:
                    symbol = cruisecontrol_emergency_unset.copy()
            else:
                if cruisecontrolspeed == targetspeed:
                    if auto_accelerate == True and DefaultSteering.enabled == True:
                        if turnincoming == True:
                            symbol = cruisecontrol_emergency_slowed.copy()
                        else:
                            symbol = cruisecontrol_emergency_set.copy()
                    elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                        if turnincoming == True:
                            symbol = cruisecontrol_emergency_slowed.copy()
                        else:
                            symbol = cruisecontrol_emergency_set.copy()
                    else:
                        symbol = cruisecontrol_emergency_unset.copy()
                elif trafficlight_accelerate == True and trafficlight_allow_acceleration == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_emergency_slowed.copy()
                    else:
                        symbol = cruisecontrol_emergency_set.copy()
                elif auto_accelerate == True and DefaultSteering.enabled == True:
                    if turnincoming == True:
                        symbol = cruisecontrol_emergency_slowed.copy()
                    else:
                        symbol = cruisecontrol_emergency_set.copy()
                else:
                    symbol = cruisecontrol_emergency_unset.copy()
                if user_braking == True or user_accelerating == True:
                    symbol = cruisecontrol_emergency_unset.copy()
        
        symbol_resized = cv2.resize(symbol, (int(0.4 * height), int(0.234375 * height)))
        target_region = frame[int(height/2.8 - 0.2 * height):int(height/2.8 + 0.034375 * height), width - int(0.4 * height):width]
        if indicator_left or indicator_right:
            target_region = frame[int(height/2.8 - 0.2 * height):int(height/2.8 + 0.034375 * height), width - int(0.4 * height):width]
        else:
            target_region = frame[int(height/4 - 0.2 * height):int(height/4 + 0.034375 * height), width - int(0.4 * height):width]
        target_region[:symbol_resized.shape[0], :symbol_resized.shape[1]] = symbol_resized

    if allow_acceleration == False:
        current_text = &#34;Acceleration&#34;
        width_target_current_text = 0.2*width
        fontscale_current_text = 1
        textsize_current_text, _ = cv2.getTextSize(current_text, cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, 1)
        width_current_text, height_current_text = textsize_current_text
        max_count_current_text = 3
        while width_current_text != width_target_current_text:
            fontscale_current_text *= width_target_current_text / width_current_text if width_current_text != 0 else 1
            textsize_current_text, _ = cv2.getTextSize(current_text, cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, 1)
            width_current_text, height_current_text = textsize_current_text
            max_count_current_text -= 1
            if max_count_current_text &lt;= 0:
                break
        thickness_current_text = round(fontscale_current_text*2)
        if thickness_current_text &lt;= 0:
            thickness_current_text = 1
        textsize_paused_text, _ = cv2.getTextSize(&#34;Paused&#34;, cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, 1)
        width_paused_text, height_paused_text = textsize_paused_text
        if indicator_left or indicator_right:
            if show_symbols == True:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.4*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.4*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
            else:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.5*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.5*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
        else:
            if show_symbols == True:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.3*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.3*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
            else:
                cv2.putText(frame, current_text, (round(0.79*width), round(0.4*height+height_current_text)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)
                cv2.putText(frame, &#34;Paused&#34;, (round(0.89*width-width_paused_text/2), round(0.4*height+height_current_text*2.5)), cv2.FONT_HERSHEY_SIMPLEX, fontscale_current_text, (0, 0, 255), thickness_current_text)

    if show_symbols == True:
        try:
            data[&#34;frame&#34;] = frame
        except:
            pass
    
    last_park_brake = park_brake
    last_lanedetected = lanedetected
    last_do_lanedetected_stop = do_lanedetected_stop
    last_hazard_light = hazard_light
    last_cruisecontrolspeed = cruisecontrolspeed
    return data # Plugins need to ALWAYS return the data</code></pre>
</details>
</dd>
</dl>
</section>
<section>
<h2 class="section-title" id="header-classes">Classes</h2>
<dl>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI"><code class="flex name class">
<span>class <span class="ident">UI</span></span>
<span>(</span><span>master)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">class UI():
    try: # The panel is in a try loop so that the logger can log errors if they occur

        def __init__(self, master) -&gt; None:
            self.master = master # &#34;master&#34; is the mainUI window
            self.exampleFunction()
            resizeWindow(900,600)
        
        def tabFocused(self):
            resizeWindow(900,600)
        
        def destroy(self):
            self.done = True
            self.root.destroy()
            del self
        
        def UpdateScaleValueFromSlider(self):
            self.acceleration.set(self.accelerationSlider.get())
            self.brake.set(self.brakeSlider.get())
            settings.CreateSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, self.accelerationSlider.get())
            settings.CreateSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, self.brakeSlider.get())
            UpdateSettings()
        
        def exampleFunction(self):
            try:
                self.root.destroy() 
            except: pass
            
            self.root = tk.Canvas(self.master, width=800, height=580, border=0, highlightthickness=0)
            self.root.grid_propagate(0) 
            self.root.pack_propagate(0)
            
            notebook = ttk.Notebook(self.root)
            notebook.pack(anchor=&#34;center&#34;, fill=&#34;both&#34;, expand=True)
            
            generalFrame = ttk.Frame(notebook)
            generalFrame.pack()
            
            generalFrame.columnconfigure(0, weight=1)
            generalFrame.columnconfigure(1, weight=1)
            generalFrame.columnconfigure(2, weight=1)
            helpers.MakeLabel(generalFrame, &#34;General&#34;, 0, 0, font=(&#34;Robot&#34;, 12, &#34;bold&#34;), columnspan=3)

            notebook.add(generalFrame, text=Translate(&#34;General&#34;))
            
            self.root.pack(anchor=&#34;center&#34;, expand=False)
            self.root.update()
            
            helpers.MakeCheckButton(generalFrame, &#34;Automatically enable cruise control when available.&#34;, &#34;CruiseControl&#34;, &#34;auto_enable&#34;, 2, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Stop the truck when a red traffic light is detected.\n(requires that the TrafficLightDetection plugin is enabled)&#34;, &#34;CruiseControl&#34;, &#34;stop_trafficlight&#34;, 3, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically accelerate when the red traffic light turns green.&#34;, &#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, 4, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically accelerate to the target speed, even if your truck is standing still.\n(if you disable the steering or pause this feature, the truck will not accelerate to the target speed)&#34;, &#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, 5, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically enable the hazard light, when the user does a emergency stop.&#34;, &#34;CruiseControl&#34;, &#34;auto_hazard&#34;, 6, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Automatically come to a stop and enable the hazard light if no lane is detected.&#34;, &#34;CruiseControl&#34;, &#34;auto_stop&#34;, 7, 0, width=90, callback=lambda: UpdateSettings())
            helpers.MakeCheckButton(generalFrame, &#34;Show Cruise Control symbol in the Lane Assist window. (ShowImage Plugin)&#34;, &#34;CruiseControl&#34;, &#34;show_symbols&#34;, 8, 0, width=90, callback=lambda: UpdateSettings())
            
            self.accelerationSlider = tk.Scale(generalFrame, from_=0, to=100, resolution=1, orient=tk.HORIZONTAL, length=480, command=lambda x: self.UpdateScaleValueFromSlider())
            self.accelerationSlider.set(settings.GetSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, 50))
            self.accelerationSlider.grid(row=9, column=0, padx=10, pady=0, columnspan=2)
            self.acceleration = helpers.MakeComboEntry(generalFrame, &#34;Acceleration\nstrength in %&#34;, &#34;CruiseControl&#34;, &#34;acceleration&#34;, 9, 0)
            
            self.brakeSlider = tk.Scale(generalFrame, from_=0, to=100, resolution=1, orient=tk.HORIZONTAL, length=480, command=lambda x: self.UpdateScaleValueFromSlider())
            self.brakeSlider.set(settings.GetSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, 100))
            self.brakeSlider.grid(row=10, column=0, padx=10, pady=0, columnspan=2)
            self.brake = helpers.MakeComboEntry(generalFrame, &#34;Brake\nstrength in %&#34;, &#34;CruiseControl&#34;, &#34;brake&#34;, 10, 0)

            helpers.MakeLabel(generalFrame, &#34;For the best experience, you need to go in the game settings under Gameplay and enable\nthe Adaptive cruise control to the highest possible distance and set the Emergency brake\nsystem to Full detection!&#34;, 11, 0, sticky=&#34;w&#34;)

        def update(self, data): # When the panel is open this function is called each frame 
            self.root.update()
    
    
    except Exception as ex:
        print(ex.args)</code></pre>
</details>
<h3>Methods</h3>
<dl>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.UpdateScaleValueFromSlider"><code class="name flex">
<span>def <span class="ident">UpdateScaleValueFromSlider</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def UpdateScaleValueFromSlider(self):
    self.acceleration.set(self.accelerationSlider.get())
    self.brake.set(self.brakeSlider.get())
    settings.CreateSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, self.accelerationSlider.get())
    settings.CreateSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, self.brakeSlider.get())
    UpdateSettings()</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.destroy"><code class="name flex">
<span>def <span class="ident">destroy</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def destroy(self):
    self.done = True
    self.root.destroy()
    del self</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.exampleFunction"><code class="name flex">
<span>def <span class="ident">exampleFunction</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def exampleFunction(self):
    try:
        self.root.destroy() 
    except: pass
    
    self.root = tk.Canvas(self.master, width=800, height=580, border=0, highlightthickness=0)
    self.root.grid_propagate(0) 
    self.root.pack_propagate(0)
    
    notebook = ttk.Notebook(self.root)
    notebook.pack(anchor=&#34;center&#34;, fill=&#34;both&#34;, expand=True)
    
    generalFrame = ttk.Frame(notebook)
    generalFrame.pack()
    
    generalFrame.columnconfigure(0, weight=1)
    generalFrame.columnconfigure(1, weight=1)
    generalFrame.columnconfigure(2, weight=1)
    helpers.MakeLabel(generalFrame, &#34;General&#34;, 0, 0, font=(&#34;Robot&#34;, 12, &#34;bold&#34;), columnspan=3)

    notebook.add(generalFrame, text=Translate(&#34;General&#34;))
    
    self.root.pack(anchor=&#34;center&#34;, expand=False)
    self.root.update()
    
    helpers.MakeCheckButton(generalFrame, &#34;Automatically enable cruise control when available.&#34;, &#34;CruiseControl&#34;, &#34;auto_enable&#34;, 2, 0, width=90, callback=lambda: UpdateSettings())
    helpers.MakeCheckButton(generalFrame, &#34;Stop the truck when a red traffic light is detected.\n(requires that the TrafficLightDetection plugin is enabled)&#34;, &#34;CruiseControl&#34;, &#34;stop_trafficlight&#34;, 3, 0, width=90, callback=lambda: UpdateSettings())
    helpers.MakeCheckButton(generalFrame, &#34;Automatically accelerate when the red traffic light turns green.&#34;, &#34;CruiseControl&#34;, &#34;trafficlight_accelerate&#34;, 4, 0, width=90, callback=lambda: UpdateSettings())
    helpers.MakeCheckButton(generalFrame, &#34;Automatically accelerate to the target speed, even if your truck is standing still.\n(if you disable the steering or pause this feature, the truck will not accelerate to the target speed)&#34;, &#34;CruiseControl&#34;, &#34;auto_accelerate&#34;, 5, 0, width=90, callback=lambda: UpdateSettings())
    helpers.MakeCheckButton(generalFrame, &#34;Automatically enable the hazard light, when the user does a emergency stop.&#34;, &#34;CruiseControl&#34;, &#34;auto_hazard&#34;, 6, 0, width=90, callback=lambda: UpdateSettings())
    helpers.MakeCheckButton(generalFrame, &#34;Automatically come to a stop and enable the hazard light if no lane is detected.&#34;, &#34;CruiseControl&#34;, &#34;auto_stop&#34;, 7, 0, width=90, callback=lambda: UpdateSettings())
    helpers.MakeCheckButton(generalFrame, &#34;Show Cruise Control symbol in the Lane Assist window. (ShowImage Plugin)&#34;, &#34;CruiseControl&#34;, &#34;show_symbols&#34;, 8, 0, width=90, callback=lambda: UpdateSettings())
    
    self.accelerationSlider = tk.Scale(generalFrame, from_=0, to=100, resolution=1, orient=tk.HORIZONTAL, length=480, command=lambda x: self.UpdateScaleValueFromSlider())
    self.accelerationSlider.set(settings.GetSettings(&#34;CruiseControl&#34;, &#34;acceleration&#34;, 50))
    self.accelerationSlider.grid(row=9, column=0, padx=10, pady=0, columnspan=2)
    self.acceleration = helpers.MakeComboEntry(generalFrame, &#34;Acceleration\nstrength in %&#34;, &#34;CruiseControl&#34;, &#34;acceleration&#34;, 9, 0)
    
    self.brakeSlider = tk.Scale(generalFrame, from_=0, to=100, resolution=1, orient=tk.HORIZONTAL, length=480, command=lambda x: self.UpdateScaleValueFromSlider())
    self.brakeSlider.set(settings.GetSettings(&#34;CruiseControl&#34;, &#34;brake&#34;, 100))
    self.brakeSlider.grid(row=10, column=0, padx=10, pady=0, columnspan=2)
    self.brake = helpers.MakeComboEntry(generalFrame, &#34;Brake\nstrength in %&#34;, &#34;CruiseControl&#34;, &#34;brake&#34;, 10, 0)

    helpers.MakeLabel(generalFrame, &#34;For the best experience, you need to go in the game settings under Gameplay and enable\nthe Adaptive cruise control to the highest possible distance and set the Emergency brake\nsystem to Full detection!&#34;, 11, 0, sticky=&#34;w&#34;)</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.tabFocused"><code class="name flex">
<span>def <span class="ident">tabFocused</span></span>(<span>self)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def tabFocused(self):
    resizeWindow(900,600)</code></pre>
</details>
</dd>
<dt id="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.update"><code class="name flex">
<span>def <span class="ident">update</span></span>(<span>self, data)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def update(self, data): # When the panel is open this function is called each frame 
    self.root.update()</code></pre>
</details>
</dd>
</dl>
</dd>
</dl>
</section>
</article>
<nav id="sidebar">
<h1>Index</h1>
<div class="toc">
<ul></ul>
</div>
<ul id="index">
<li><h3>Super-module</h3>
<ul>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl" href="index.html">Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl</a></code></li>
</ul>
</li>
<li><h3><a href="#header-functions">Functions</a></h3>
<ul class="">
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UpdateSettings" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UpdateSettings">UpdateSettings</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.onDisable" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.onDisable">onDisable</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.onEnable" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.onEnable">onEnable</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.plugin" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.plugin">plugin</a></code></li>
</ul>
</li>
<li><h3><a href="#header-classes">Classes</a></h3>
<ul>
<li>
<h4><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI">UI</a></code></h4>
<ul class="">
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.UpdateScaleValueFromSlider" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.UpdateScaleValueFromSlider">UpdateScaleValueFromSlider</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.destroy" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.destroy">destroy</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.exampleFunction" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.exampleFunction">exampleFunction</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.tabFocused" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.tabFocused">tabFocused</a></code></li>
<li><code><a title="Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.update" href="#Euro-Truck-Simulator-2-Lane-Assist.plugins.CruiseControl.main.UI.update">update</a></code></li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</main>
<footer id="footer">
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.10.0</a>.</p>
</footer>
</body>
</html>